/*************************************************************************************
*Copyright (c) 2011, Intel Mobile Communications GmbH. 
*All rights reserved.
*
*Redistribution and use in source and binary forms, with or without
*modification, are permitted provided that the following conditions are met:
*    * Redistributions of source code must retain the above copyright
*      notice, this list of conditions and the following disclaimer.
*    * Redistributions in binary form must reproduce the above copyright
*      notice, this list of conditions and the following disclaimer in the
*      documentation and/or other materials provided with the distribution.
*    * Neither the name of the <organization> nor the
*      names of its contributors may be used to endorse or promote products
*      derived from this software without specific prior written permission.
*
*THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
*ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
*WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
*DISCLAIMED. IN NO EVENT SHALL INTEL MOBILE COMMUNICATIONS GMBH. BE LIABLE FOR ANY
*DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
*(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
*LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
*ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
*(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
*SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*************************************************************************************/



#include "cef_system.h"
using namespace std;
cef_system::cef_system()
{
	system_properties=NULL;
	domains=NULL;
	blocks=NULL;
	links=NULL;
	routes=NULL;
}
cef_system::cef_system(cef_system_properties* p,std::vector<cef_domain*>* d,std::vector<cef_block*>* b,std::vector<cef_link*>* l, cef_routes* r)
{
	system_properties=p;	
	domains=d;
	blocks=b;
	links=l;
	routes=r;
}
cef_system::~cef_system()
{
	if(system_properties) delete system_properties;
	if(domains)
	{
		for(unsigned i=0;i<domains->size();i++)
		{
			delete (*domains)[i];
		}
		delete domains;
	}
	if(blocks)
	{
		for(unsigned i=0;i<blocks->size();i++)
		{
			delete (*blocks)[i];
		}
		delete blocks;
	}
	if(links)
	{
		for(unsigned i=0;i<links->size();i++)
		{
			delete (*links)[i];
		}
		delete links;
	}
	if(routes)
	{
		delete routes;
	}
}
//Setters
void cef_system::setProperties(cef_system_properties* s)
{
	system_properties=s;
}
void cef_system::setDomains(std::vector<cef_domain*>* d)
{
	domains=d;
}
void cef_system::setBlocks(std::vector<cef_block*>* b)
{
	blocks=b;
}
void cef_system::setLinks(std::vector<cef_link*>* l)
{
	links=l;
}
void cef_system::setRoutes(cef_routes* r)
{
	routes=r;
}

//Getters
cef_system_properties* cef_system::getProperties()
{
	return system_properties;
}
std::vector<cef_domain*>* cef_system::getDomains()
{
	return domains;
}
std::vector<cef_block*>* cef_system::getBlocks()
{
	return blocks;
}
std::vector<cef_link*>* cef_system::getLinks()
{
	return links;
}
cef_routes* cef_system::getRoutes()
{
	return routes;
}
#ifdef _DEBUG
void cef_system::print()
{
	cout<<"CEF System\nBEGIN\n";	
	if(system_properties) system_properties->print();
	if(domains)
	{
		for(unsigned i=0;i<domains->size();i++)
		{	
			(*domains)[i]->print();
		}
	}
	if(blocks)
	{
		for(unsigned i=0;i<blocks->size();i++)
		{	
			(*blocks)[i]->print();
		}
	}
	if(links)
	{
		for(unsigned i=0;i<links->size();i++)
		{	
			(*links)[i]->print();
		}
	}
	if(routes)
	{
			routes->print();
	}
	cout<<"END\n";
}
#endif
